using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class So_TransfersMap : EntityTypeConfiguration<So_Transfers>
    {
        public So_TransfersMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Number, t.Date, t.Source, t.Destination });

            // Properties
            this.Property(t => t.Number)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.User)
                .HasMaxLength(30);

            this.Property(t => t.Transfer_Type)
                .HasMaxLength(3);

            this.Property(t => t.Source)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.Destination)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.Customer)
                .HasMaxLength(110);

            // Table & Column Mappings
            this.ToTable("So_Transfers");
            this.Property(t => t.Number).HasColumnName("Number");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.User).HasColumnName("User");
            this.Property(t => t.Transfer_Type).HasColumnName("Transfer_Type");
            this.Property(t => t.Source).HasColumnName("Source");
            this.Property(t => t.Destination).HasColumnName("Destination");
            this.Property(t => t.Customer).HasColumnName("Customer");
            this.Property(t => t.Order__).HasColumnName("Order_#");
        }
    }
}
